'use strict';
const RuleList = {
    idList: [],
    nameList: [],
    nameKeyList: [],
    titleKeyList: ["自选五星", "原神"],
};


function openTab(e) {// 点击标签时执行此函数
// 获取所有标签布局
    const tabs = document.querySelectorAll(".tab");
    for (let v of tabs) {
        v.classList.remove("active");
    }
    const tempE = document.querySelector(`#${e}`);
    tempE.classList.add("active");
}


let href = Util.getWindowUrl();
console.log("当前网页url=" + href);
setInterval(() => {//每秒监听网页中的url
    const tempUrl = Util.getWindowUrl();
    if (href === tempUrl) return;
    //没有变化就结束本轮
    //有变化就执行对应事件
    console.log("页面url发生变化了，原=" + href + " 现=" + tempUrl);
    href = tempUrl;//更新url
    Entrance(href);//网页url发生变化时执行
}, 500);

Layout.addLayout();

RuleCRUDLayoutVue.returnVue();

// EntranceOne(href);

$("#tabUl>li>button").click((e) => {
    const domElement = e.delegateTarget;
    document.querySelectorAll("#tabUl>li>button").forEach((value, key, parent) => {
        $(value).css("color", "");
    })
    domElement.style.color = "#1b00ff";
    openTab(domElement.value);
});

$(document).keyup(function (event) {//单按键监听-按下之后松开事件
    const keycode = event.keyCode;
    switch (keycode) {
        case 192: {//按下`按键显示隐藏面板
            window.LayoutVue.show = !window.LayoutVue.show;
            break;
        }
    }
});